import { createRouter, createWebHashHistory } from 'vue-router';
// import HomeView from '../views/HomeView.vue';

const router = createRouter({
  history: createWebHashHistory(),
  // history: createWebHistory(import.meta.env.BASE_URL),
  // 路由滚动行为定制
  scrollBehavior() {
    return {
      top: 0,
    };
  },
  routes: [
    {
      path: '/',
      component: () => import('@/views/layout/index.vue'),
      children: [
        {
          path: '/',
          component: () => import('@/views/home/index.vue'),
        },
        {
          path: 'category/:id',
          component: () => import('@/views/category/index.vue'),
        },
        // 二级面包屑
        {
          path: '/category/sub/:id',
          component: () => import('@/views/subCategory/index.vue'),
        },
        // 详情页
        {
          path: 'detail/:id',
          component: () => import('@/views/detail/index.vue'),
        },
        {
          path: 'cartlist',
          component: () => import('@/views/cartList/index.vue'),
        },
        {
          path: 'checkout',
          component: () => import('@/views/checkOut/index.vue'),
        },
        {
          path: 'pay',
          component: () => import('@/views/pay/index.vue'),
        },
        {
          path: 'paycallback',
          component: () => import('@/views/pay/payBack.vue'),
        },
        {
          path: 'member',
          component: () => import('@/views/member/index.vue'),
          children: [
            {
              path: '',
              redirect: '/user',
            },
            {
              path: '/user',
              component: () => import('@/views/member/component/userInfo.vue'),
            },
            {
              path: 'order',
              component: () => import('@/views/member/component/userOrder.vue'),
            },
          ],
        },
      ],
    },
    {
      path: '/login',
      component: () => import('@/views/login/index.vue'),
    },
  ],
});

export default router;
